--------------------------------------------------------------------------------
      name:  <unnamed>
       log:  E:\Seagate Sync\VOL\Personal folder\Documents\Research\Past project
> s\cbld\Posted\121020 Website\Data analysis\cbld-management03-exp02.log
  log type:  text
 opened on:  21 Oct 2012, 15:41:07

. 
. 
. * ****************************************************************************
> *
. * Processing of results of computational experiment 2 for further data analysi
> s
. * ****************************************************************************
> *
. 
. * Programme:    cbld-management03-exp02.do
. * Project:              Council coalition building
. * Author:               Frank Haege, Department of Politics and Administration
> , University of Limerick
. * Contact:              frank.haege@ul.ie
. 
. * Description
. *************
. * This do-file uses the simulation results of the second computational experim
> ent
. * to generate data sets of predicted consensus rates and consensus rates expec
> ted by chance. 
. * The do-file also demonstrates how the 'typical' case illustrated in the arti
> cle (Figure 3) 
. * was identified.
. 
. 
. * Set up Stata
. version 11

. clear all

. macro drop _all

. set linesize 80

. set more off

. 
. * Load data set
. use "Experiments\Experiment02\cbld-model-121020-exp02.dta", clear

. 
. * Generate dichotomous consensus variable
. generate consensus = 0

. replace consensus = 1 if noblock == nostates
(35005 real changes made)

. label var consensus "Consensus decision"

. tab consensus, m

  Consensus |
   decision |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |      6,995       16.65       16.65
          1 |     35,005       83.35      100.00
------------+-----------------------------------
      Total |     42,000      100.00

. 
. 
. * Identify 'typical' case for illustration in article
. *****************************************************
. 
. tab consensus if nostates == 25 & vthresh == 72 & sequence == 1, m

  Consensus |
   decision |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |        148       14.80       14.80
          1 |        852       85.20      100.00
------------+-----------------------------------
      Total |      1,000      100.00

. * Most decisions are made by consensus
. tab nocoal if nostates == 25 & vthresh == 72 & sequence == 1, m

  Number of |
 coalitions |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |         66        6.60        6.60
          2 |        879       87.90       94.50
          3 |         55        5.50      100.00
------------+-----------------------------------
      Total |      1,000      100.00

. tab nocoal if nostates == 25 & vthresh == 72 & sequence == 1 & consensus == 1,
>  m

  Number of |
 coalitions |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |         66        7.75        7.75
          2 |        752       88.26       96.01
          3 |         34        3.99      100.00
------------+-----------------------------------
      Total |        852      100.00

. * Most cases end with two coalitions negotiating a compromise
. tab firstmax if nostates == 25 & vthresh == 72 & sequence == 1, m

    Size of |
    largest |
  coalition |
     (first |
 criterion) |      Freq.     Percent        Cum.
------------+-----------------------------------
          9 |         34        3.40        3.40
         13 |        169       16.90       20.30
         14 |        164       16.40       36.70
         15 |        145       14.50       51.20
         16 |        144       14.40       65.60
         17 |        130       13.00       78.60
         18 |         23        2.30       80.90
         19 |         32        3.20       84.10
         20 |         31        3.10       87.20
         21 |         18        1.80       89.00
         22 |         28        2.80       91.80
         23 |         11        1.10       92.90
         24 |          5        0.50       93.40
         25 |         66        6.60      100.00
------------+-----------------------------------
      Total |      1,000      100.00

. tab firstmax if nostates == 25 & vthresh == 72 & sequence == 1 & consensus == 
> 1, m

    Size of |
    largest |
  coalition |
     (first |
 criterion) |      Freq.     Percent        Cum.
------------+-----------------------------------
          9 |         34        3.99        3.99
         13 |        169       19.84       23.83
         14 |        164       19.25       43.08
         15 |        145       17.02       60.09
         16 |        144       16.90       77.00
         17 |        130       15.26       92.25
         25 |         66        7.75      100.00
------------+-----------------------------------
      Total |        852      100.00

. tab firstmax if nostates == 25 & vthresh == 72 & sequence == 1 & consensus == 
> 1 & nocoal == 2, m

    Size of |
    largest |
  coalition |
     (first |
 criterion) |      Freq.     Percent        Cum.
------------+-----------------------------------
         13 |        169       22.47       22.47
         14 |        164       21.81       44.28
         15 |        145       19.28       63.56
         16 |        144       19.15       82.71
         17 |        130       17.29      100.00
------------+-----------------------------------
      Total |        752      100.00

. * In most cases, the largest coalition has 8 members
. tab step if nostates == 25 & vthresh == 72 & sequence == 1, m

       Time |
    periods |      Freq.     Percent        Cum.
------------+-----------------------------------
          2 |          6        0.60        0.60
          3 |        642       64.20       64.80
          4 |        334       33.40       98.20
          5 |         18        1.80      100.00
------------+-----------------------------------
      Total |      1,000      100.00

. tab step if nostates == 25 & vthresh == 72 & sequence == 1 & consensus == 1 & 
> nocoal == 2 & firstmax == 13, m

       Time |
    periods |      Freq.     Percent        Cum.
------------+-----------------------------------
          3 |        116       68.64       68.64
          4 |         49       28.99       97.63
          5 |          4        2.37      100.00
------------+-----------------------------------
      Total |        169      100.00

. * In most cases, the coalition-building process lasts three time-steps
. sum meandist if nostates == 25 & vthresh == 72 & sequence == 1, d

               Mean distance between positions
-------------------------------------------------------------
      Percentiles      Smallest
 1%         9.15            8.4
 5%          9.7            8.9
10%           10              9       Obs                1000
25%         10.5              9       Sum of Wgt.        1000

50%           11                      Mean            10.9773
                        Largest       Std. Dev.      .7432544
75%         11.5           12.8
90%         11.9           12.9       Variance       .5524271
95%         12.2           12.9       Skewness      -.1387699
99%         12.6           13.2       Kurtosis       2.961301

. sum meandist if nostates == 25 & vthresh == 72 & sequence == 1 & consensus == 
> 1 & nocoal == 2 & firstmax == 13 & step == 3, d

               Mean distance between positions
-------------------------------------------------------------
      Percentiles      Smallest
 1%          9.4            9.3
 5%          9.7            9.4
10%          9.9            9.4       Obs                 116
25%        10.45            9.5       Sum of Wgt.         116

50%           11                      Mean           10.95776
                        Largest       Std. Dev.      .7445046
75%         11.5           12.4
90%         11.9           12.4       Variance       .5542871
95%         12.2           12.4       Skewness      -.0594788
99%         12.4           12.8       Kurtosis       2.577101

. * Identify typical cases
. list rseed nostates vthresh if nostates == 25 & vthresh == 72 & sequence == 1 
> & consensus == 1 /*
>         */ & nocoal == 2 & firstmax == 13 & step == 3 & meandist == r(p50)

       +-------------------------------+
       |    rseed   nostates   vthresh |
       |-------------------------------|
 1067. | 12032001         25        72 |
 3755. | 12032065         25        72 |
11609. | 12032252         25        72 |
19211. | 12032433         25        72 |
26645. | 12032610         25        72 |
       |-------------------------------|
39875. | 12032925         25        72 |
       +-------------------------------+

. * Case with random seed 12032065 is illustrated in the article
. 
. 
. * Generate data sets of predicted consensus rates and consensus rates expected
>  by chance
. ******************************************************************************
> **********
. 
. * Collapse data by combination of move sequence, membership size, and voting t
> hreshold
. sort nostates vthresh

. collapse (mean) consensus=consensus, by(sequence nostates vthresh)

. label var consensus "Expected consensus (model)"

. 
. * Generate standard error of proportion
. generate se = sqrt(consensus*(1-consensus)/1000)

. label var se "Standard error (model)"

. 
. * Generate lower and upper bound of confidence interval
. generate lowerci = (consensus - (1.96 * se))

. label var lowerci "CI lower bound (model)"

. generate upperci = (consensus + (1.96 * se))

. label var upperci "CI upper bound (model)"

.         
. * Generate rule-member state period variable
. generate rulemembersize = .
(42 missing values generated)

. replace rulemembersize = 1 if nostates == 12 & vthresh == 72
(2 real changes made)

. replace rulemembersize = 2 if nostates == 15 & vthresh == 72
(2 real changes made)

. replace rulemembersize = 3 if nostates == 25 & vthresh == 72
(2 real changes made)

. replace rulemembersize = 4 if nostates == 27 & vthresh == 74
(2 real changes made)

. replace rulemembersize = 5 if nostates == 27 & vthresh == 65
(2 real changes made)

. label var rulemembersize "Rule-membership period"

. label define rulemembersizel /*
>         */ 1 "Pre-Nice 12" /*
>         */ 2 "Pre-Nice 15" /*
>         */ 3 "Nice 25" /*
>         */ 4 "Nice 27" /*
>         */ 5 "Lisbon 27", modify

. label val rulemembersize rulemembersizel

. 
. * Merge with expected consensus rates data
. merge m:1 nostates using "Experiments\Other data\cbld-management02.dta"
nostates was byte now float

    Result                           # of obs.
    -----------------------------------------
    not matched                            24
        from master                        24  (_merge==1)
        from using                          0  (_merge==2)

    matched                                18  (_merge==3)
    -----------------------------------------

. drop _merge

. 
. * Drop redundant observations
. drop if rulemembersize == .
(32 observations deleted)

. 
. * Generate dataset based on model with random execution
. sort sequence nostates vthresh

. preserve

.         * Drop redundant data points
.         keep if sequence == 1
(5 observations deleted)

. 
.         * Save data set
.         sort rulemembersize

.         save "Experiments\Experiment02\cbld-management03-exp02a.dta", replace
file Experiments\Experiment02\cbld-management03-exp02a.dta saved

. restore

. 
. * Generate dataset based on model with ordered execution
. preserve

.         * Drop redundant data points
.         keep if sequence == 2
(5 observations deleted)

. 
.         * Save data set
.         sort rulemembersize

.         save "Experiments\Experiment02\cbld-management03-exp02b.dta", replace
file Experiments\Experiment02\cbld-management03-exp02b.dta saved

. restore

. 
. * Save entire data set
. sort sequence rulemembersize

. compress
nostates was float now byte
rulemembersize was float now byte

. save "Experiments\Experiment02\cbld-management03-exp02.dta", replace
file Experiments\Experiment02\cbld-management03-exp02.dta saved

.         
.         
. * Exit do-file  
. log close
      name:  <unnamed>
       log:  E:\Seagate Sync\VOL\Personal folder\Documents\Research\Past project
> s\cbld\Posted\121020 Website\Data analysis\cbld-management03-exp02.log
  log type:  text
 closed on:  21 Oct 2012, 15:41:08
--------------------------------------------------------------------------------
